package com.capgemini.simpleappblanche.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.capgemini.simpleappblanche.dao.IAgencyDao;
import com.capgemini.simpleappblanche.domain.Agency;
import com.capgemini.simpleappblanche.dto.AgencyDto;
import com.capgemini.simpleappblanche.services.IAgencyService;
import com.capgemini.simpleappblanche.utils.AppMapper;

@Service
@Transactional
public class AgencyService implements IAgencyService {
	
    @Autowired
    private IAgencyDao agencyDao;

    @Autowired
	private AppMapper mapperDozer;
    
    
	/**
	 * constructor
	 */
	public AgencyService() {
		super();
	}
	/**
	 * constructor
	 * @param customerDao customerDao
	 * @param mapperDozer mapperDozer
	 */
	public AgencyService(IAgencyDao agencyDao, AppMapper mapperDozer) {
		super();
		this.agencyDao = agencyDao;
		this.mapperDozer = mapperDozer;
	}

	
	

	/**
	 * {@inheritDoc}
	 * @see com.capgemini.simpleappblanche.services.IAgencyService#findAllActive()
	 */
	@Override
	public List<AgencyDto> findAllActive() {
	    final List<Agency> result =  agencyDao.findAllActive();
		
		return mapperDozer.mapList(result, AgencyDto.class);
	}
	
	
    /**
     * {@inheritDoc}
     * @see com.capgemini.simpleappblanche.services.IAgencyService#findActiveByIds(java.util.List)
     */
    @Override
    public List<AgencyDto> findActiveByIds(List<Long> agencyIds) {
	    final List<Agency> result =  agencyDao.findActiveByIds(agencyIds);
		
		return mapperDozer.mapList(result, AgencyDto.class);
    }

}
